package click;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class FakeClike {

    public static Map<String, String> blogMap;
    /**
     * 找到的代理ip和port
     */
    public static List<IpAndPort> ipAndPortList;
    /**
     * 开启多少个线程来跑程序
     */
    public static int threadNum = 30;

    public static void main(String[] args) throws IOException {
        try {
            FakeClike.runTest();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(-1);
        }
    }

    public static void runTest() throws IOException, InterruptedException {
        // 设置要刷的博客名字
        String blogName = "qq_37933685";

        //        String blogName = "qq_33720683";

        blogMap = new HashMap<String, String>();
        blogMap = CM.getBlogLinkList(blogName);

        //存储博客链接
        //        File blog = new File("click/blogmap");
        //        FileOutputStream outputStream = new FileOutputStream(blog);
        //        for (String b : blogMap.keySet()) {
        //            String s = blogMap.get(b)+"\n";
        //            outputStream.write(s.getBytes());
        //        }
        //        outputStream.close();

        if (blogMap == null || blogMap.size() <= 0) {
            System.out.println("没有找到需要刷的博客链接");
            return;
        }
        for (Map.Entry<String, String> entry : blogMap.entrySet()) {
            System.out.println(entry.getKey());
        }
        //2.从本地列表中取数据(建议网上爬完数据后,就切换为本地列表)
        //        ipAndPortList = CM.getTotalListFromFile("click/aliveIP.txt");

        ScheduledExecutorService scheduledExecutorService = new ScheduledThreadPoolExecutor(1);
        scheduledExecutorService
            .scheduleAtFixedRate(new FindProxy(10), 1, 10 * 60, TimeUnit.SECONDS);

    }


}
